package GameServer.core;

import GameServer.Demo;
import GameServer.manager.event.EventMgr;
import GameServer.net.Netmodule;
import GameServer.util.ExecutorPool;

/**
 * Created by gzhd on 2017/11/29.
 */
public class GameInit {
    public static volatile int state=0;


    public static boolean start(){
        Demo.print("启动逻辑服务器");
        GameInit.state=1;
        Demo.print("启动网络模块");
        Netmodule.getInstance().startNet();
        Demo.print("初始化线程池");
        ExecutorPool.InitThreadsExecutor();
        Demo.print("启动事件处理器");
        EventMgr.getInstance().init();
        Demo.print("初始化消息路由和功能模块");
        Router.getInstance().initData();
//        Demo.print("开启定时任务调度");
        return  true;
    }

    public static boolean shut() {
        Demo.print("关闭逻辑服务器...");
        GameInit.state = 0;
        Demo.print("关闭网络模块");
        Netmodule.getInstance().shutNet();
        Demo.print("关闭定时任务调度");
//        JobMgr.getInstance().stopJobs();
        Demo.print("关闭事件处理器");
        EventMgr.shutdown();
        return true;
    }
}
